//
//  QMQCCureTypeController.m
//  QcMedical1
//
//  Created by 仲启明 on 2016/12/22.
//  Copyright © 2016年 jiawen Du. All rights reserved.
//

#import "QMQCCureTypeController.h"

@interface QMQCCureTypeController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, copy) NSString *cureTypeText;

@end

@implementation QMQCCureTypeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    [self.view addSubview:tableView];
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cure"];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
    
    
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    
    titleLabel.text =  @"治疗方式";
    
    titleLabel.font = [UIFont fontWithName:@"CloudShuiZhuGBK" size:18];
    self.navigationItem.titleView = titleLabel;
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cure" forIndexPath:indexPath];
    
    
    if (indexPath.row == 0) {
        
        cell.textLabel.text = @"吃枣药丸💊";
    }else if (indexPath.row == 1){
        cell.textLabel.text = @"药不能停💊";

    }else if (indexPath.row == 2){
        cell.textLabel.text = @"放弃治疗💊";

    }else if (indexPath.row == 3){
        cell.textLabel.text = @"在家等死💊";

    }else if (indexPath.row == 4){
        cell.textLabel.text = @"💊💊💊💊";

    }
    
    cell.textLabel.font = [UIFont fontWithName:@"CloudShuiZhuGBK" size:15];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell =  tableView.visibleCells[indexPath.row];
    
    self.cureTypeText = cell.textLabel.text;
    NSLog(@"%@",self.cureTypeText);
    if (_cureType) {
            _cureType(self.cureTypeText);
      
            }
  
    [self.navigationController popViewControllerAnimated:YES];
}

@end
